<?php 
$queries = array(
    "CREATE TABLE IF NOT EXISTS `administrator` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `username` varchar(50) CHARACTER SET latin1 NOT NULL,
      `password` varchar(50) CHARACTER SET latin1 NOT NULL,
      `email` varchar(255) CHARACTER SET latin1 NOT NULL,
      `created` datetime NOT NULL,
      `lastLogin` datetime DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",

    "CREATE TABLE IF NOT EXISTS `administrator_permission` (
      `administratorId` int(10) unsigned NOT NULL,
      `permissionId` int(10) unsigned NOT NULL,
      `siteId` int(10) unsigned DEFAULT NULL,
      `accessLevel` int(10) unsigned NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",

    "CREATE TABLE IF NOT EXISTS `custom_field` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `name` varchar(100) NOT NULL,
      `valueDisplayType` tinyint(1) NOT NULL,
      `value` text,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
            
    "CREATE TABLE IF NOT EXISTS `page` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `title` varchar(50) CHARACTER SET latin1 NOT NULL,
      `urlTitle` varchar(50) CHARACTER SET latin1 NOT NULL,
      `content` text,
      `template` varchar(255) CHARACTER SET latin1 NOT NULL,
      `status` tinyint(1) NOT NULL,
      `parentId` int(10) unsigned DEFAULT NULL,
      `rewriteId` int(11) unsigned DEFAULT NULL,
      `siteId` int(11) unsigned NOT NULL,
      `weight` tinyint(3) NOT NULL,
      `level` int(3) unsigned NOT NULL,
      `childrenSortOrder` tinyint(3) unsigned NOT NULL,
      `created` datetime NOT NULL,
      `updated` datetime NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",

    "CREATE TABLE IF NOT EXISTS `page_custom_field` (
      `pageId` int(10) unsigned NOT NULL,
      `customFieldId` int(10) unsigned NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
            
    "CREATE TABLE IF NOT EXISTS `permission` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `title` varchar(255) CHARACTER SET latin1 NOT NULL,
      `subject` varchar(255) CHARACTER SET latin1 NOT NULL,
      `type` enum('system','content') CHARACTER SET latin1 NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",

    "CREATE TABLE IF NOT EXISTS `rewrite` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `siteId` int(10) unsigned NOT NULL,
      `permalink` varchar(255) CHARACTER SET latin1 NOT NULL,
      `rewriteTo` varchar(255) CHARACTER SET latin1 NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",

    "CREATE TABLE IF NOT EXISTS `setting` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `name` varchar(100) NOT NULL,
      `label` varchar(100) NOT NULL,
      `value` varchar(255) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",

    "CREATE TABLE IF NOT EXISTS `site` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `code` varchar(255) CHARACTER SET latin1 NOT NULL,
      `name` varchar(255) CHARACTER SET latin1 NOT NULL,
      `url` varchar(255) NOT NULL,
      `theme` varchar(100) CHARACTER SET latin1 NOT NULL,
      `timezone` varchar(50) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",

    "CREATE TABLE IF NOT EXISTS `site_custom_field` (
      `siteId` int(10) unsigned NOT NULL,
      `customFieldId` int(10) unsigned NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"
);
